﻿//-------------------------------------------------------------------
//	Copyright (c) 2012  Zhirnov Andrey
//	This file is part of the "OGL-Tools" project.
//	See copyright notice in "HeaderGenerator.h".
//-------------------------------------------------------------------

#pragma once

#include "HeaderGenerator.h"

namespace HeaderGenerator
{

	//
	// Code Generator
	//

	class CCodeGenerator
	{
	private:
		struct THook
		{
			string	sOverriden;
			string	sHookName;
		};

		IFilePtr		_pOutputFuncs,
						_pOutputEnums,
						_pOutputDef;
		array<THook>	_aOverriden;

	private:
		bool _ProcessOverride(const char *pOverride);
		bool _ProcessHeader(const char *pHeader);
		void _ProcessFunctions(const uni_c_string &sData, const uni_c_string &sPrefix, usize uOffset);
		void _ProcessEnums(const uni_c_string &sData, const uni_c_string &sPrefix, usize uOffset);
		bool _CheckHook(const uni_c_string &sFuncName, string &sHookName);

	public:
		CCodeGenerator();
		~CCodeGenerator();

		bool Generate(	const uni_array<const char *> &aInputHeaders,
						const char * pOverride,
						const char * pOutputFuncs,
						const char * pOutputEnums,
						const char * pOutputDef );
	};

}	// HeaderGenerator
